package asia.kalin.controller;

import asia.kalin.domain.ao.Result;
import asia.kalin.domain.dto.CameraCollectionDTO;
import asia.kalin.service.ICameraService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Kalin
 * @Name：CameraController
 * @Date: 2025/3/12
 * @description
 */

@RestController
@RequestMapping("/camera")
@RequiredArgsConstructor
public class CameraController {

    private final ICameraService cameraService;

    /**
     * 查询所有摄像头的位置及基本信息
     * @return Result
     */
    @GetMapping("/queryCameraList")
    public Result getCameraLocationList(){
        return cameraService.getCameraLocationList();
    }

    /**
     * 根据id查询出摄像头详情
     * @param cameraId 摄像头id
     * @return Result
     */
    @GetMapping("/getCameraById")
    public Result getCameraById(@RequestParam String cameraId){
        return cameraService.queryCameraById(cameraId);
    }

    /**
     * 查询出当前摄像头拍摄的所有检测结果信息
     * @param cameraId 摄像头id
     * @return Result
     */
    @GetMapping("/getResultByCId")
    public Result getResultListByCameraId(@RequestParam String cameraId){
        return cameraService.getResultListByCameraId(cameraId);
    }

    /**
     * 收藏摄像头id
     * @param collectionDTO 摄像头id
     * @return Result
     */
    @PostMapping("/cameraCollection")
    public Result collectionCameraLocation(@RequestBody CameraCollectionDTO collectionDTO){
        System.out.println(collectionDTO);
        return cameraService.collectionCameraLocation(collectionDTO);
    }

    /**
     * 查询当前用户收藏的所有摄像头地点
     * @return Result
     */
    @GetMapping("/getCollectionCameraAll")
    public Result getUserCollectionCameraAll(){
        return cameraService.getUserCollectionCameraAll();
    }

    /**
     * 查询当前用户是否收藏当前摄像头
     * @param cameraId 摄像头id
     * @return
     */
    @GetMapping("/isCollection")
    public Result isCollectionById(@RequestParam String cameraId){
        return cameraService.isCollectionById(cameraId);
    }

}
